/**
 * js中class仅仅是原型的语法糖，为方便封装与代码组织，以下采用class的方式
 */

 class Father {
   constructor(name, year) {
      this.right = true
      this.name = 'Father'
      this.year = 88
   }

   consoleName() {
     console.log('it is : ' + this.name)
   }
 }

 class BigSon extends Father {
   constructor(name, year) {
     super()
     this.name = name
     this.year = year
   }

   consoleName() {
     console.log('it is : ' + this.name)
   }
 }

 class SmallSon extends Father {
   constructor(name, year) {
     super()
     this.name = name
     this.year = year
   }

   consoleName() {
     console.log('it is : ' + this.name)
   }
 }

// 打印私有属性
const bigSon = new BigSon('da mao', 18)
const smallSon = new SmallSon('xiao mao', 9)

bigSon.consoleName()
smallSon.consoleName()

console.log(bigSon.__proto__)
console.log(smallSon.__proto__)

console.log(BigSon.prototype)
console.log(SmallSon.prototype)

console.log(BigSon.prototype.constructor)
console.log(SmallSon.prototype.constructor)


console.log('对象bigSon是否有私有属性name: ' + bigSon.hasOwnProperty('name'))
console.log('对象bigSon是否有私有属性right: ' + bigSon.hasOwnProperty('right'))

console.log('类BigSon是否有私有属性name: ' + BigSon.hasOwnProperty('name'))
console.log('类BigSon是否有私有属性right: ' + BigSon.hasOwnProperty('right'))

console.log('对象smallSon是否有私有属性name: ' + smallSon.hasOwnProperty('name'))
console.log('对象smallSon是否有私有属性right: ' + smallSon.hasOwnProperty('right'))

console.log('类SmallSon是否有私有属性name: ' + SmallSon.hasOwnProperty('name'))
console.log('类SmallSon是否有私有属性right: ' + SmallSon.hasOwnProperty('right'))

console.log(BigSon.__proto__)
